package com.easy.customer.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.easy.common.bean.CustomerContacts;
import com.easy.common.bean.Product;
import com.easy.common.service.ICustomerContactsService;
import com.easy.common.util.ResultData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("customercontacts")
public class CustomerContactsController {
    @Autowired
    ICustomerContactsService customerContactsService;

    @PostMapping("/")
    public ResultData insert(@RequestBody CustomerContacts customerContacts) {
        CustomerContacts data=customerContactsService.insert(customerContacts);
        return ResultData.success(data);
    }
    @PutMapping("/")
    public ResultData update(@RequestBody CustomerContacts customerContacts) {
        CustomerContacts data=customerContactsService.update(customerContacts);
        return ResultData.success(data);
    }
    @DeleteMapping("/{id}")
    public ResultData delete(@PathVariable Integer id) {
        int result=customerContactsService.delete(id);
        if(result>=1){
            return ResultData.success("200","删除成功",null);
        } else {
            return ResultData.fail();
        }
    }
    @GetMapping("/{id}")
    public ResultData getByID(@PathVariable Integer id) {
        CustomerContacts contacts=customerContactsService.getByID(id);
        return ResultData.success(contacts);
    }
}
